@extends('layouts.admin')

@section('title', '班级配置-添加成员')

@section('style')
    <link rel="stylesheet" type="text/css" href="{{asset('lib/bootstrap/css/multiple-select.css')}}" />
@endsection

@section('content')
    <article class="page-container">
        <form method="post" id="form-techValue-add">
            <input type="hidden" name="clbum_id" value="{{$clbum_id}}">
            <select multiple="multiple" class="multiple" name="students[]" id="students" style="width:300px">
                @foreach ($students as $da)
                    <option value="{{$da->id}}">{{$da->name}}</option>
                @endforeach
            </select><button type="submit" class="btn btn-default" id="search_button">确认添加</button>
        </form>
    </article>
@endsection
@section('script')
    <script type="text/javascript" src="{{asset('lib/bootstrap/multiple-select.js')}}?snt=1"></script>
    <script>
        $("#students").multipleSelect({
            filter: true,
            placeholder: "请选择班级成员"
        });
        $("#form-techValue-add").validate({
            rules:{
                students:{
                    required:true
                }
            },
            onkeyup:false,
            focusCleanup:true,
            success:"valid",
            submitHandler:function(form){
                $(form).ajaxSubmit({
                    type: 'post',
                    url: "{{url('clbum/clbum/addStudent')}}",
                    success: function(data){
                        if(data['successFlag']==1){
                            layer_success_message("添加成功!");
                            setTimeout(function(){
                                parent.$(".btnSearch").click();
                                layer_close();
                            },500);
                        }else{
                            layer_error_message(data['msg']);
                        }
                    },
                    error: function(XmlHttpRequest, textStatus, errorThrown){
                        layer_error_message('添加失败!');
                    }
                });
            }
        });
    </script>
@endsection